import 'package:core_package/cache/user_cache.dart';
import 'package:flutter/cupertino.dart';
import 'package:core_package/core_package.dart';
import 'package:flutter_app_unionad/model/promotion_materials_model.dart';

class Configuration {
  static Configuration? _instance;

  factory Configuration() => _sharedInstance();

  static List<PromotionMaterialsModel>? promotionList;

  //私有构造方法
  Configuration._();

  static Configuration _sharedInstance() {
    if (_instance == null) {
      _instance = Configuration._();
    }
    return _instance!;
  }

  String? _phone;
  String? _maxCount;
  String? _price;

  // ignore: unnecessary_getters_setters
  String get phone => _phone ?? "";

  // ignore: unnecessary_getters_setters
  set phone(String value) {
    _phone = value;
  }

  // ignore: unnecessary_getters_setters
  String get maxCount => _maxCount ?? "";

  // ignore: unnecessary_getters_setters
  set maxCount(String value) {
    _maxCount = value;
  }

  // ignore: unnecessary_getters_setters
  String get price => _price ?? "";

  // ignore: unnecessary_getters_setters
  set price(String value) {
    _price = value;
  }

  static const String userId = 'USERID';
  static const h5Share = 'https://www.51uuid.com/tgh5/share/detail.html?invitePhone=';

  static const String deviceId = 'DEVCEID';
  static const String makeAnInstall = 'MAKEANINSTALL';
  static const String mobile = 'MOBILE';
  static const String openid = 'OPENID';
  static const String userType = 'USERTYPE';
  static const String adTime = 'ADTIME';
  static const String adUrl = 'ADURL';

  ///极光推送id
  static const String jsPushRegisterId = 'jsPushRegisterId';

  static loginOut() {
    UserCacheUil.setInt(userId, 0);
    UserCacheUil.setString(deviceId, "");
    UserCacheUil.setString(mobile, "");
    UserCacheUil.setString(openid, "");
    UserCacheUil.setInt(userType, 0);
    UserCacheUil.setBool(makeAnInstall, false);
  }

  call() {
    if (phone.stringIsEmpty) {
      return;
    }
    CallsAndMessagesService.call(phone);
  }
}

endKeyboard(BuildContext context) {
  FocusScope.of(context).requestFocus(FocusNode());
}
